﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- Facebook Pixel Code -->
<script>
  !function(f,b,e,v,n,t,s)
  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
  n.callMethod.apply(n,arguments):n.queue.push(arguments)};
  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
  n.queue=[];t=b.createElement(e);t.async=!0;
  t.src=v;s=b.getElementsByTagName(e)[0];
  s.parentNode.insertBefore(t,s)}(window, document,'script',
  'https://connect.facebook.net/en_US/fbevents.js');
  fbq('init', '205095903581751');
  fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
  src="https://www.facebook.com/tr?id=205095903581751&ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="yes" name="apple-touch-fullscreen" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="320" name="MobileOptimized" />
    <meta content="telephone=no" name="format-detection" />


    <title>大馬代購 爆款Ultra Boost鞋，價格優惠！錯過要後悔一整年！</title>

    <link href="../Scripts/Mall/css/cart.css" rel="stylesheet" />
    <link href="../Scripts/Mall/css/reset.css" rel="stylesheet" />
    <script src="../Scripts/Mall/jquery.min.js"></script>
    <script src="../Scripts/Mall/main.js"></script>
    <script src="../Scripts/Mall/not3.js"></script>
    <style type="text/css">
    input.error::-webkit-input-placeholder {
      color: red;
    }
    input.error:-moz-placeholder {
      color: red;
    }
    input.error:-ms-input-placeholder {
      color: red;
    }
    </style>
    
</head>
<body>
    <div class="g-bd">
        <div class="m-hd" style="background: #fff;">
            <div class="m-topBar">
                <a class="goback" onclick="javascript :history.back(-1)"></a>
                <div style="width: 100%;">
                    <div class="title">收貨信息</div>
                </div>
            </div>
        </div>

        <!--  -->
        <div id="order">
            <div class="warp">
               

                    <input type="hidden" id="item_id" name="item_id" value="" />
                    <input type="hidden" id="item_price" name="item_price" value="" />

                    <!--套餐-->
                    <div class="m-goodItems">
                    <div class="referimg"></div>


                        <!--产品目录-->

                        <ul class="m-list m-attrs" style="margin-bottom: 10px; background: #fff">
                            <li class="item u-format" style="padding: 7px 0px;">
                                <div class="tt">套餐:<span id="combo_choosed"></span></div>

                                <div class="con" style="font-size: 16px;" id="comb">
                                    <input type="hidden" id="combo_id" value="1">
                                    
                                </div>

                                <div class="cls"></div>
                            </li>
                        </ul>


                        <!-- 修改套餐属性切换 -->
                        <!--产品套餐属性-->
                        <section>
                            <ul class="m-list m-attrs" style="margin-bottom: 10px;">
                                <div class="tc tc1343">
                                    <li class="item u-format" style="overflow: hidden; border-bottom: solid 1px #ddd; margin-bottom: 5px;">
                                        <div class="tt" style="line-height: 18px;">
                                            產品: <span id="combo_display"></span>
                                        </div>
                                    </li>

                                    <li class="item protoLayer">



                                        



                                        



                                    </li>
                                </div>
                            </ul>
                        </section>

                        <ul class="m-list m-attrs" style="margin-bottom: 10px;">
                            <li class="item" style="margin: 10px 0px; padding-bottom: 5px;">
                                <div class="u-format">
                                    <div class="tt">數量</div>
                                    <div class="con">
                                        <div class="m-selnum dr">
                                            <div class="less z-dis" onclick="minnumber()"></div>
                                            <div class="textWrap">
                                                <input id="num" onblur="inputnumber();" name="qty" type="text" value="1" />
                                            </div>
                                            <div class="more" onclick="addnumber()"></div>
                                        </div>
                                    </div>
                                    <div style="clear: both;"></div>
                                </div>
                            </li>
                        </ul>
                    </div>

                    <div class="u-icon u-address-bg"></div>
                    <div class="address-input">




                        <!-- 姓名 -->
                        <div class="buy-single-row label-input">
                            <label>
                                <div class="input-label">
                                    <div class="cell fixed">姓名</div>
                                </div>
                                <div class="cell">
                                    <input type="text" name="shipping_firstname" maxlength="250" required="" placeholder="請輸入姓名，如張三" class="inputText" id="id_shipping_firstname" />
                                </div>
                            </label>
                        </div>

                        <!-- 手機 -->
                        <div class="buy-single-row label-input">
                            <label>
                                <div class="input-label">
                                    <div class="cell fixed">手機</div>
                                </div>
                                <div class="cell">
                                    <input type="text" name="shipping_phone" maxlength="20" required="" placeholder="請輸入手機號碼" class="inputText" id="id_shipping_phone">
                                </div>
                            </label>
                        </div>

                        <!-- 郵箱 -->
                        <div class="buy-single-row label-input">
                            <label>
                                <div class="input-label">
                                    <div class="cell fixed">郵箱</div>
                                </div>
                                <div class="cell">
                                    <input type="text" name="email" id="id_email" placeholder="請輸入常用EMAIL郵箱" class="inputText" maxlength="250" />
                                </div>
                            </label>
                        </div>

                        <!-- 詳細地址 -->
                        <div class="buy-single-row label-input">
                            <label>
                                <div class="input-label">
                                    <div class="cell fixed">地区</div>
                                </div>
                                <div class="cell">
                                    <select id="province" name="shipping_state" style="display: none;">
                                    </select>
                                    <select id="city" name="shipping_city" required="">
                                    </select>
                                    <select id="area" name="shipping_area" required="">
                                    </select>
                                    <span class="regioninfo" style="color:red"></span>
                                </div>
                            </label>
                        </div>

                        <div class="buy-single-row label-input">
                            <label>
                                <div class="input-label">
                                    <div class="cell fixed"></div>
                                </div>
                                <div class="cell">
                                    <input type="text" name="shipping_address" maxlength="250" required="" placeholder="街道門牌信息" class="inputText" id="id_shipping_address">
                                </div>
                            </label>
                        </div>

                        <div class="buy-single-row label-input" style="display: none">
                            <label>
                                <div class="input-label">
                                    <div class="cell fixed">郵編</div>
                                </div>
                                <div class="cell">
                                    <input type="text" name="shipping_zipcode" id="id_shipping_zipcode" class="inputText" maxlength="16">
                                </div>
                            </label>
                        </div>

                        <div class="buy-single-row label-input">
                            <label>
                                <div class="input-label">
                                    <div class="cell fixed">付款方式</div>
                                </div>
                                <div class="cell">
                                    <input name="payment_type" value="0" checked="" type="radio" style="float: left; margin-top: 13px;" /><span style="margin-top: 10px; float: left; line-height: 30px;"><img src="../images/cod.png" /></span>
                                </div>
                            </label>
                        </div>
                        <div class="buy-single-row label-input">
                            <label>
                                <div class="input-label">
                                    <div class="cell fixed">留言</div>
                                </div>
                                <div class="cell" style="line-height: 18px;">
                                    <textarea name="comment" style="margin-top: 10px; height: 48px; padding: 0px;" rows="10" id="id_comment" placeholder="如包裹送達時段、是否送至警衛，備用聯繫電話" cols="40" class="inputText"></textarea>

                                </div>
                            </label>
                        </div>

                        <!--  -->
                        <div style="padding: 10px; background-color: #fff; text-align: right;">
                            <div class="line">
                                <span>共</span>
                                <span id="cart_count">1</span>
                                <span>件商品</span>
                                <span>合計:</span>
                                <span class="price">
                                    <span class="red">NT$</span>
                                    <span class="red" id="amount">1199</span>
                                    <input type="hidden" name="price" value="" readonly="" class="value" style="width: 80px; border: none; text-align: center;">
                                </span>圓
                            </div>
                        </div>

                        <!--  -->
                        <div style="text-align: center; margin: 10px 0px;">
                            <button class="btnBuy" type="submit" name="Submit">立即購買</button>
                        </div>
                        <!--  -->
                        <div style="padding: 15px; background: #fff; font-size: 14px; color: #666; text-align: left; margin-top: 10px;">
                            溫馨提示：支持貨到付款+免郵費+7天鑒賞期！收到貨有任何疑問請聯繫我們在線客服! 也可隨時聯繫:<a href="mailto:trouble@gogodealss.com%E2%80%8D"><!--email_off-->trouble@gogodealss.com<!--/email_off-->‍</a>。同時請附上您的姓名及聯繫方式及訂單編號在郵件當中，以便我們能快速的給您及時處理，祝您購物愉快！！！
                        </div>

                        <div style="clear: both;"></div>
                    </div>
               
            </div>
        </div>
    </div>

    <script>
/*
        var items = Array();
        var size = "";
        var color = "";
        var combo = "";


        items["1|824|男款紅色|36"] = { 'id': 11651, 'price': 1199.0 };
        items["1|824|男款紅色|37"] = { 'id': 11652, 'price': 1199.0 };
        items["1|824|男款紅色|38"] = { 'id': 11653, 'price': 1199.0 };
        items["1|824|男款紅色|39"] = { 'id': 11654, 'price': 1199.0 };
        items["1|824|男款紅色|40"] = { 'id': 11655, 'price': 1199.0 };
        items["1|824|男款紅色|41"] = { 'id': 11656, 'price': 1199.0 };
        items["1|824|男款紅色|42"] = { 'id': 11657, 'price': 1199.0 };
        items["1|824|男款紅色|43"] = { 'id': 11658, 'price': 1199.0 };
        items["1|824|男款紅色|44"] = { 'id': 11659, 'price': 1199.0 };
        items["1|824|男款黑色|36"] = { 'id': 11660, 'price': 1199.0 };
        items["1|824|男款黑色|37"] = { 'id': 11661, 'price': 1199.0 };
        items["1|824|男款黑色|38"] = { 'id': 11662, 'price': 1199.0 };
        items["1|824|男款黑色|39"] = { 'id': 11663, 'price': 1199.0 };
        items["1|824|男款黑色|40"] = { 'id': 11664, 'price': 1199.0 };
        items["1|824|男款黑色|41"] = { 'id': 11665, 'price': 1199.0 };
        items["1|824|男款黑色|42"] = { 'id': 11666, 'price': 1199.0 };
        items["1|824|男款黑色|43"] = { 'id': 11667, 'price': 1199.0 };
        items["1|824|男款黑色|44"] = { 'id': 11668, 'price': 1199.0 };
        items["1|824|女款紅色|36"] = { 'id': 11669, 'price': 1199.0 };
        items["1|824|女款紅色|37"] = { 'id': 11670, 'price': 1199.0 };
        items["1|824|女款紅色|38"] = { 'id': 11671, 'price': 1199.0 };
        items["1|824|女款紅色|39"] = { 'id': 11672, 'price': 1199.0 };
        items["1|824|女款紅色|40"] = { 'id': 11673, 'price': 1199.0 };
        items["1|824|女款紅色|41"] = { 'id': 11674, 'price': 1199.0 };
        items["1|824|女款紅色|42"] = { 'id': 11675, 'price': 1199.0 };
        items["1|824|女款紅色|43"] = { 'id': 11676, 'price': 1199.0 };
        items["1|824|女款紅色|44"] = { 'id': 11677, 'price': 1199.0 };
        items["1|824|女款黑色|36"] = { 'id': 11678, 'price': 1199.0 };
        items["1|824|女款黑色|37"] = { 'id': 11679, 'price': 1199.0 };
        items["1|824|女款黑色|38"] = { 'id': 11680, 'price': 1199.0 };
        items["1|824|女款黑色|39"] = { 'id': 11681, 'price': 1199.0 };
        items["1|824|女款黑色|40"] = { 'id': 11682, 'price': 1199.0 };
        items["1|824|女款黑色|41"] = { 'id': 11683, 'price': 1199.0 };
        items["1|824|女款黑色|42"] = { 'id': 11684, 'price': 1199.0 };
        items["1|824|女款黑色|43"] = { 'id': 11685, 'price': 1199.0 };
        items["1|824|女款黑色|44"] = { 'id': 11686, 'price': 1199.0 };
        items["2|824|男款紅色|36"] = { 'id': 11687, 'price': 1199.0 };
        items["2|824|男款紅色|37"] = { 'id': 11688, 'price': 1199.0 };
        items["2|824|男款紅色|38"] = { 'id': 11689, 'price': 1199.0 };
        items["2|824|男款紅色|39"] = { 'id': 11690, 'price': 1199.0 };
        items["2|824|男款紅色|40"] = { 'id': 11691, 'price': 1199.0 };
        items["2|824|男款紅色|41"] = { 'id': 11692, 'price': 1199.0 };
        items["2|824|男款紅色|42"] = { 'id': 11693, 'price': 1199.0 };
        items["2|824|男款紅色|43"] = { 'id': 11694, 'price': 1199.0 };
        items["2|824|男款紅色|44"] = { 'id': 11695, 'price': 1199.0 };
        items["2|824|男款黑色|36"] = { 'id': 11696, 'price': 1199.0 };
        items["2|824|男款黑色|37"] = { 'id': 11697, 'price': 1199.0 };
        items["2|824|男款黑色|38"] = { 'id': 11698, 'price': 1199.0 };
        items["2|824|男款黑色|39"] = { 'id': 11699, 'price': 1199.0 };
        items["2|824|男款黑色|40"] = { 'id': 11700, 'price': 1199.0 };
        items["2|824|男款黑色|41"] = { 'id': 11701, 'price': 1199.0 };
        items["2|824|男款黑色|42"] = { 'id': 11702, 'price': 1199.0 };
        items["2|824|男款黑色|43"] = { 'id': 11703, 'price': 1199.0 };
        items["2|824|男款黑色|44"] = { 'id': 11704, 'price': 1199.0 };
        items["2|824|女款紅色|36"] = { 'id': 11705, 'price': 1199.0 };
        items["2|824|女款紅色|37"] = { 'id': 11706, 'price': 1199.0 };
        items["2|824|女款紅色|38"] = { 'id': 11707, 'price': 1199.0 };
        items["2|824|女款紅色|39"] = { 'id': 11708, 'price': 1199.0 };
        items["2|824|女款紅色|40"] = { 'id': 11709, 'price': 1199.0 };
        items["2|824|女款紅色|41"] = { 'id': 11710, 'price': 1199.0 };
        items["2|824|女款紅色|42"] = { 'id': 11711, 'price': 1199.0 };
        items["2|824|女款紅色|43"] = { 'id': 11712, 'price': 1199.0 };
        items["2|824|女款紅色|44"] = { 'id': 11713, 'price': 1199.0 };
        items["2|824|女款黑色|36"] = { 'id': 11714, 'price': 1199.0 };
        items["2|824|女款黑色|37"] = { 'id': 11715, 'price': 1199.0 };
        items["2|824|女款黑色|38"] = { 'id': 11716, 'price': 1199.0 };
        items["2|824|女款黑色|39"] = { 'id': 11717, 'price': 1199.0 };
        items["2|824|女款黑色|40"] = { 'id': 11718, 'price': 1199.0 };
        items["2|824|女款黑色|41"] = { 'id': 11719, 'price': 1199.0 };
        items["2|824|女款黑色|42"] = { 'id': 11720, 'price': 1199.0 };
        items["2|824|女款黑色|43"] = { 'id': 11721, 'price': 1199.0 };
        items["2|824|女款黑色|44"] = { 'id': 11722, 'price': 1199.0 };


        $(document).ready(function () {

            combo = $("#combo_id").val();
            if (!combo) {
                combo = "";
            }

            color = $("#color_id").val();
            if (!color) {
                color = "";
            }

            size = $("#size_id").val();
            if (!size) {
                size = "";
            }

            update_item(combo = combo, color = color, size = size);


            $('.combo_option').click(function () {
                combo = $(this).attr('data-id');
                $(this).addClass('tab-sel').siblings().removeClass('tab-sel');
                $("#combo_display").html($(this).attr("name-id"));

                update_item(combo = combo, color = color, size = size);
            });




            image = $(".color_option:first").attr("data-img");
            $("#item_img").attr("src", image);

            /*
            $('.protoLayer .con label').click(function(event) {
                $(this).addClass('active').siblings().removeClass('active');
                color = $(this).attr('data-id');
                image = $(this).attr("data-img");
                $("#item_img").attr("src", image);
                update_item(combo=combo, color=color, size=size);
            });
            

            $(".color_option").click(function () {
                color = $(this).attr('data-id');
                $(this).parent().addClass('active').siblings().removeClass('active');
                image = $(this).attr("data-img");
                $("#item_img").attr("src", image);

                update_item(combo = combo, color = color, size = size);
            });




            $('.size_option').click(function () {
                size = $(this).attr('data-id');
                $(this).parent().addClass('active').siblings().removeClass('active');
                update_item(combo = combo, color = color, size = size);
            });


        });*/

        function update_item(combo, color, size) {
            item_id = items[key]['id'];
            item_price = items[key]['price'];
            $('#item_id').attr('value', item_id);
            $('#item_price').attr('value', item_price);
            $('#price_display').html(item_price);

            qty = $('#num').val();
            $('#amount').html(item_price * qty);
        }
    </script>

    <script>
        var addressInit = function (_cmbProvince, _cmbCity, _cmbArea, defaultProvince, defaultCity, defaultArea) {
            var cmbProvince = document.getElementById(_cmbProvince);
            var cmbCity = document.getElementById(_cmbCity);
            var cmbArea = document.getElementById(_cmbArea);

            function cmbSelect(cmb, str) {
                for (var i = 0; i < cmb.options.length; i++) {
                    if (cmb.options[i].value == str) {
                        cmb.selectedIndex = i;
                        return;
                    }
                }
            }
            function cmbAddOption(cmb, str, obj) {
                var option = document.createElement("OPTION");
                cmb.options.add(option);
                option.innerHTML = str;
                if (str == "") {
                    if (obj == null) {
                        option.innerHTML = "鄉鎮市區";
                    } else {
                        option.innerHTML = "請選取縣市";
                    }

                } else {
                    option.innerHTML = str;
                }
                option.value = str;
                option.obj = obj;
            }

            function changeCity() {
                cmbArea.options.length = 0;
                if (cmbCity.selectedIndex == -1) return;
                var item = cmbCity.options[cmbCity.selectedIndex].obj;
                for (var i = 0; i < item.areaList.length; i++) {
                    cmbAddOption(cmbArea, item.areaList[i], null);
                }
                cmbSelect(cmbArea, defaultArea);
            }
            function changeProvince() {
                cmbCity.options.length = 0;
                cmbCity.onchange = null;
                if (cmbProvince.selectedIndex == -1) return;
                var item = cmbProvince.options[cmbProvince.selectedIndex].obj;
                for (var i = 0; i < item.cityList.length; i++) {
                    cmbAddOption(cmbCity, item.cityList[i].name, item.cityList[i]);
                }
                cmbSelect(cmbCity, defaultCity);
                changeCity();
                cmbCity.onchange = changeCity;
            }

            for (var i = 0; i < provinceList.length; i++) {
                cmbAddOption(cmbProvince, provinceList[i].name, provinceList[i]);
            }
            cmbSelect(cmbProvince, defaultProvince);
            changeProvince();
            cmbProvince.onchange = changeProvince;
        };


        var provinceList = [
            {
                name: '台灣', cityList: [
                   { name: '', areaList: ['', ] },
                   { name: '基隆市', areaList: ['仁愛區', '信義區', '中正區', '中山區', '安樂區', '暖暖區', '七堵區'] },
                   { name: '台北市', areaList: ['中正區', '大同區', '中山區', '松山區', '大安區', '萬華區', '信義區', '士林區', '北投區', '內湖區', '南港區', '文山區'] },
                   { name: '新北市', areaList: ['板橋區', '新莊區', '泰山區', '林口區', '淡水區', '金山區', '八里區', '萬里區', '石門區', '三芝區', '瑞芳區', '汐止區', '平溪區', '貢寮區', '雙溪區', '深坑區', '石碇區', '新店區', '坪林區', '烏來區', '中和區', '永和區', '土城區', '三峽區', '樹林區', '鶯歌區', '三重區', '蘆洲區', '五股區'] },
                   { name: '桃園市', areaList: ['桃園區', '中壢區', '平鎮區', '八德區', '楊梅區', '蘆竹區', '龜山區', '龍潭區', '大溪區', '大園區', '觀音區', '新屋區', '復興區'] },
                   { name: '新竹市', areaList: ['東區', '北區', '香山區'] },
                   { name: '新竹縣', areaList: ['竹北市', '竹東鎮', '新埔鎮', '關西鎮', '峨眉鄉', '寶山鄉', '北埔鄉', '橫山鄉', '芎林鄉', '湖口鄉', '新豐鄉', '尖石鄉', '五峰鄉'] },
                   { name: '苗栗縣', areaList: ['苗栗市', '通霄鎮', '苑裡鎮', '竹南鎮', '頭份市', '後龍鎮', '卓蘭鎮', '西湖鄉', '頭屋鄉', '公館鄉', '銅鑼鄉', '三義鄉', '造橋鄉', '三灣鄉', '南庄鄉', '大湖鄉', '獅潭鄉', '泰安鄉'] },
                   { name: '台中市', areaList: ['中區', '東區', '南區', '西區', '北區', '北屯區', '西屯區', '南屯區', '太平區', '大里區', '霧峰區', '烏日區', '豐原區', '后里區', '東勢區', '石崗區', '新社區', '和平區', '神岡區', '潭子區', '大雅區', '大肚區', '龍井區', '沙鹿區', '梧棲區', '清水區', '大甲區', '外埔區', '大安區'] },
                   { name: '彰化縣', areaList: ['彰化市', '員林市', '和美鎮', '鹿港鎮', '溪湖鎮', '二林鎮', '田中鎮', '北斗鎮', '花壇鄉', '芬園鄉', '大村鄉', '永靖鄉', '伸港鄉', '線西鄉', '福興鄉', '秀水鄉', '埔心鄉', '埔鹽鄉', '大城鄉', '芳苑鄉', '竹塘鄉', '社頭鄉', '二水鄉', '田尾鄉', '埤頭鄉', '溪州鄉'] },
                   { name: '南投縣', areaList: ['南投市', '埔里鎮', '草屯鎮', '竹山鎮', '集集鎮', '名間鄉', '鹿谷鄉', '中寮鄉', '魚池鄉', '國姓鄉', '水里鄉', '信義鄉', '仁愛鄉'] },
                   { name: '雲林縣', areaList: ['斗六市', '斗南鎮', '虎尾鎮', '西螺鎮', '土庫鎮', '北港鎮', '莿桐鄉', '林內鄉', '古坑鄉', '大埤鄉', '崙背鄉', '二崙鄉', '麥寮鄉', '台西鄉', '東勢鄉', '褒忠鄉', '四湖鄉', '口湖鄉', '水林鄉', '元長鄉'] },
                   { name: '嘉義市', areaList: ['東區', '西區'] },
                   { name: '嘉義縣', areaList: ['太保市', '朴子市', '布袋鎮', '大林鎮', '民雄鄉', '溪口鄉', '新港鄉', '六腳鄉', '東石鄉', '義竹鄉', '鹿草鄉', '水上鄉', '中埔鄉', '竹崎鄉', '梅山鄉', '番路鄉', '大埔鄉', '阿里山鄉'] },
                   { name: '台南市', areaList: ['中西區', '東區', '南區', '北區', '安平區', '安南區', '永康區', '歸仁區', '新化區', '左鎮區', '玉井區', '楠西區', '南化區', '仁德區', '關廟區', '龍崎區', '官田區', '麻豆區', '佳里區', '西港區', '七股區', '將軍區', '學甲區', '北門區', '新營區', '後壁區', '白河區', '東山區', '六甲區', '下營區', '柳營區', '鹽水區', '善化區', '大內區', '山上區', '新市區', '安定區'] },
                   { name: '高雄市', areaList: ['楠梓區', '左營區', '鼓山區', '三民區', '鹽埕區', '前金區', '新興區', '苓雅區', '前鎮區', '小港區', '旗津區', '鳳山區', '大寮區', '鳥松區', '林園區', '仁武區', '大樹區', '大社區', '岡山區', '路竹區', '橋頭區', '梓官區', '彌陀區', '永安區', '燕巢區', '田寮區', '阿蓮區', '茄萣區', '湖內區', '旗山區', '美濃區', '內門區', '杉林區', '甲仙區', '六龜區', '茂林區', '桃源區', '那瑪夏區'] },
                   { name: '屏東縣', areaList: ['屏東市', '潮州鎮', '東港鎮', '恆春鎮', '萬丹鄉', '長治鄉', '麟洛鄉', '九如鄉', '里港鄉', '鹽埔鄉', '高樹鄉', '萬巒鄉', '內埔鄉', '竹田鄉', '新埤鄉', '枋寮鄉', '新園鄉', '崁頂鄉', '林邊鄉', '南州鄉', '佳冬鄉', '琉球鄉', '車城鄉', '滿州鄉', '枋山鄉', '霧台鄉', '瑪家鄉', '泰武鄉', '來義鄉', '春日鄉', '獅子鄉', '牡丹鄉', '三地門鄉'] },
                   { name: '台東縣', areaList: ['台東市', '成功鎮', '關山鎮', '長濱鄉', '海端鄉', '池上鄉', '東河鄉', '鹿野鄉', '延平鄉', '卑南鄉', '金峰鄉', '大武鄉', '達仁鄉', '綠島鄉', '蘭嶼鄉', '太麻里鄉'] },
                   { name: '花蓮縣', areaList: ['花蓮市', '鳳林鎮', '玉里鎮', '新城鄉', '吉安鄉', '壽豐鄉', '秀林鄉', '光復鄉', '豐濱鄉', '瑞穗鄉', '萬榮鄉', '富里鄉', '卓溪鄉'] },
                   { name: '宜蘭縣', areaList: ['宜蘭市', '羅東鎮', '蘇澳鎮', '頭城鎮', '礁溪鄉', '壯圍鄉', '員山鄉', '冬山鄉', '五結鄉', '三星鄉', '大同鄉', '南澳鄉'] },
                   { name: '澎湖縣', areaList: ['馬公市', '湖西鄉', '白沙鄉', '西嶼鄉', '望安鄉', '七美鄉'] },
                   { name: '金門縣', areaList: ['金城鎮', '金湖鎮', '金沙鎮', '金寧鄉', '烈嶼鄉', '烏坵鄉'] },
                   { name: '連江縣', areaList: ['南竿鄉', '北竿鄉', '莒光鄉', '東引鄉'] },
                ]
            },
        ];

        addressInit('province', 'city', 'area', '台灣', '請選取縣市', '鄉鎮市區');

    </script>
    <script type="text/javascript">
    var url = location.search;
    var Request = new Object();
    Request = GetRequest(url);
    var goodsname ;
    var imgurl;
    $.ajax({
        url: "goodsinfo.php",  
        type: "POST",
        dataType: "json",
        error: function(){  
            alert('Error goodsinfo.php');  
        },  
        success: function(res){//如果调用php成功 
            var data;   
            $.each(res,function(index,value){
                if (value.id==Request.id){
                    data = value;
                    imgurl=data.mainImg;
                    $('input[name=item_id]').val(data.id);
                    //$('input[name=item_price]').val(data.nowPrice);
                    $('#combo_display').html(data.name);
                    let referImg = '<img src="'+data.referImg+'" width="100%">'
                    $('.referimg').append(referImg);
                    //$('#amount').html(data.nowPrice);
                    goodsname = data.name;
                    $('title').html(data.name);
                    var style = JSON.parse(data.cates);
                    initStyle(style);
                    initCombo(JSON.parse(data.sets));

                    

                }
            });
            
        }
    });
function initCombo(combo){
     $.each(combo,function(index,value){
        if (!index){
    let html=`<p style="padding: 5px 0px;">
                    <label>
                        <input type="radio" name="combo_id" value="${value.price}" data-id="${index}" name-id="${value.name}" class="combo_option" checked="">
                        ${value.name}
                    </label>
                </p>`;
                $('#combo_id').val(value.name);
                $('#comb').append(html);
                $('input[name=item_price]').val(value.price);
                $('#amount').html(value.price);
                //$("#combo_choosed").html(value);
            }else {
                let html=`<p style="padding: 5px 0px;">
                    <label>
                        <input type="radio" name="combo_id" value="${value.price}" data-id="${index}" name-id="${value.name}" class="combo_option" >
                        ${value.name}
                    </label>
                </p>`;
                $('#comb').append(html);
            }

    });
     $('.combo_option').click(function () {
        let combo = $(this).attr('data-id');
        $(this).addClass('tab-sel').siblings().removeClass('tab-sel');
        //$("#combo_choosed").html($(this).attr("name-id"));
        $('#combo_id').val($(this).attr("name-id"));

    });

}
function initStyle(style){
    $.each(style,function(index,value){
        let html  = `<div class="u-format count_atrr">
                            <div class="tt" style="font-size: 14px;">${value.stylename}:</div>
                            <div class="con" style="width: auto;">
                                <input type="hidden" id="style${index}" value="${value.style[0].attri}" name="style"/>
                                <div class="${value.stylename}"></div>
                            </div>
                        </div>
                        <div class="cls"></div>`;
        $(".protoLayer").append(html);
        $.each(value.style,function(index2,value2){
            active = index2?"":"active";
            let html;
            if (("pic" in value2)&&(value2.pic)&&(value2.pic.length>13)){
                html  = `<label style="max-width: 94px; display: inline-block; padding: 5px; background: #eee" class="${active}">
                        <input type="radio" name="style${index}_option" data-id="${value2.attri}"  class="style${index}_option"/>
                        <img src="${value2.pic}" width="80" height="80" style="margin-bottom: 5px;" />
                        <p><span>${value2.attri}</span></p>
                    </label>`;
            }else {
                html  = `<label style="max-width: 94px; display: inline-block; padding: 5px; background: #eee" class="${active}">
                            <input type="radio" name="style${index}_option" data-id="${value2.attri}"  class="style${index}_option"/>

                            <p><span>${value2.attri}</span></p>
                        </label>`;
            }
            
        $('.protoLayer .con .'+value.stylename).append(html);
        //
        $('.protoLayer .con label').click(function(event) {
                $(this).addClass('active').siblings().removeClass('active');
            });
        $('.style'+index+'_option').click(function () {
                $('#style'+index).val($(this).attr('data-id'));
                
            });
        });
        
    });
}
//从链接中获取参数
function GetRequest(url) {
      var theRequest = new Object();
      if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for(var i = 0; i < strs.length; i ++) {
          theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
        }
      }
      return theRequest;
}

    $('.btnBuy').click(function(){
        var error=0;
        $('.regioninfo').html('');
        var buyername = $('input[name=shipping_firstname]').val();
        if(!buyername){
            $('input[name=shipping_firstname]').attr('placeholder','姓名不可为空！');
            $('input[name=shipping_firstname]').addClass('error');
            error++;
            return
        }
        var phone = $('input[name=shipping_phone]').val();
        if(!phone){
            $('input[name=shipping_phone]').attr('placeholder','手機號碼不可为空！');
            $('input[name=shipping_phone]').addClass('error');
            error++;
            return
        }
        var email = $('input[name=email]').val();
        var region = $('select[name=shipping_city]').val()+'-'+$('select[name=shipping_area]').val();
        
        if(!$('select[name=shipping_city]').val()||!$('select[name=shipping_area]').val()){
            $('.regioninfo').html('地区不可为空!');
           
            error++;
            return
        }
        var address = $('input[name=shipping_address]').val();
        if(!address){
            $('input[name=shipping_address]').attr('placeholder','地址不可为空！');
            $('input[name=shipping_address]').addClass('error');
            error++;
            return
        }
        var comment = $('textarea[name=comment]').val();
        var num = $('input[name=qty]').val();
        var price = $('#amount').html();
        var style;
        var temp=[];
        $('input[name=style]').each(function(j,item){
            temp[j]=item.value;
        });
        style = temp.join('-');
        var goodsid = $('input[name=item_id]').val();
        var combo = $('#combo_id').val();
        var data = {
            style:style,
            price:price,
            num:num,
            name:buyername,
            mobile:phone,
            region:region,
            address:address,
            mail:email,
            remark:comment,
            goodsid:goodsid,
            goodsname:goodsname,
            combo:combo
        }
        var urlvalue = "goodsid="+Request.id+"&goodsname="+goodsname+"&buyername="+buyername+"&phone="+phone+"&address="+region+"-"+address+"&num="+num+"&img="+imgurl;
    $.ajax({
        url: "orderInsert.php",  
        type: "GET",
        dataType: "json",
        data:data,
        error: function(res){  
            window.location.href = 'DropOrderSuccess.html?'+urlvalue;
        },  
        success: function(res){//如果调用php成功            
            window.location.href = 'DropOrder.html?'+urlvalue;
        }
    });
     
    })


    </script>
</body>
</html>
